#!/bin/bash

# must run this script with root

# install software
function install_software {
	apt-get install openswan
	apt-get install xl2tpd
	apt-get install pptpd
	apt-get install mysql-server
	apt-get install freeradius freeradius-mysql radiusclient1
	apt-get install nginx
	apt-get install php5 php5-mysql php5-gd php5-cgi php5-fpm php-pear php-db php5-mcrypt
}

# install config
function install_config {
	cp -rf etc /
}


# restart services
function restart_service {
	service ipsec restart
	service xl2tpd restart
	service pptpd restart
	service nginx restart
	service freeradius restart
	sysctl -p
	iptables -t nat -F POSTROUTING
	iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -o eth0 -j MASQUERADE
	iptables -t nat -A POSTROUTING -s 10.2.2.0/24 -o eth0 -j MASQUERADE
}

# main function
if [ $# == 0 ]; then
        echo "Usage: $0 software/config/restart"
        exit 1
fi

case "$1" in
        software) install_software;;
        config) install_config;;
        restart) restart_service;;
        ?)      echo "Wrong command"
                exit 1;;
esac


